package cruciverba.main;

import java.awt.GridLayout;
import java.io.FileWriter;
import java.io.IOException;

import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.JTextField;

import cruciverba.controller.MenuCtrl;
import cruciverba.controller.VerifyButton;
import cruciverba.file.CruciverbaFileWriter;
import cruciverba.file01.CruciverbaWriteLine;
import cruciverba.file01.FileWriterObserver;
import cruciverba.model.Verifica;
import cruciverba.ui.CruciverbaArea;
import cruciverba.ui.CruciverbaMenu;

public class Cruciverba {
	public static void main(String[] args) {
		
	Verifica verifica = new Verifica();
	CruciverbaArea area = new CruciverbaArea(verifica);
	CruciverbaMenu menu = new CruciverbaMenu();
	JTextField field = new JTextField("Select item from Verifiche");
	field.setEnabled(false);
	MenuCtrl menuctrl = new MenuCtrl(menu, verifica, area, field);
	
	JFrame frame = FramesUtils.createFrame("Cruciverba");
	
	frame.setJMenuBar(menu);
	
	JPanel panel = new JPanel();
	panel.setLayout(new GridLayout(3, 1));
	panel.add(field);
	panel.add(area);
	panel.add(new VerifyButton(area, verifica, field));
	
	frame.getContentPane().add(panel);

	frame.setVisible(true);
//	
//	try {
//		FileWriter writer;
//			writer = new FileWriter("Log.txt", true);			
//			CruciverbaFileWriter fileWriter = new CruciverbaFileWriter(verifica, field, writer);
//
//	} catch (IOException e) {
//		// TODO Auto-generated catch block
//		e.printStackTrace();
//	}
	
	CruciverbaWriteLine lineWriter = new CruciverbaWriteLine(verifica, field);
	FileWriterObserver filewriter = new FileWriterObserver(verifica, lineWriter, "Prova.txt");
	

	

	}
}
